<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>屏蔽关键词</title>
    <link rel="stylesheet" href="../css/layui.css">
    <script src="../js/jQuery.js"></script>
    <script src="../js/layui.js"></script>
</head>

<body>
    <script>
        var guan = ["天安门", "故宫", "北京"];
        function 屏蔽(string) {
            var str = string;
            for (let i = 0; i < guan.length; i++) {
                str = str.replaceAll(guan[i], "*".repeat(guan[i].length));
            }
            return str;
        }
        function 检测(string) {
            let str = 屏蔽(string);
            let panduan = string == str ? false : true;
            return panduan;
        }
    </script>
</body>

</html>